Core Activity
1.- Get this COARE soundings .nc data file It is 1726 soundings on a 5mb grid 1000-100 mb. (181 values).
2.- Get the IDL or Matlab codes: main ones are esat, mixrat (or saturation mixing ratio), entropy, invert_entropy.
3.- Read the COARE soundings into memory. Notice array sizes.

For fans of free software I'm attaching a code (hw1_data.csh) for reformatting the data into GrADS format.


4.- Compute q (mixing ratio) = {[0.622 *esat(T) / (p-esat(T)) ] *RH} /100 = mixingratio(esat(T),p) *RH / 100 (code mixrat.gs)
mean_qqsat.gif
5.- Compute a mean sounding by averaging T and q, let's work with that. You might want a 1D p array.
mean_T.gifmean_rh.gif
6.- Compute the entropy, total water, and pressure of a near-surface parcel. Call these s0, qt0, p0. (code entropy.gs)

entropies.gif
s0= 255.112
qt0= 0.0172868 kg/kg
p0= 985 mb

7.- Invert those conserved variables for T and qv at all other pressures using invert_entropy routine ( from 7 to 11).
Picture_15.pngPicture_22.png

8.- Compute the condensed water profile (qc = qt0 - qv) for this reversible process.
Picture_20.pngPicture_19.png
9.- Compute the density temperature Tρ profile from T, qv, and qc (or qt).
Picture_16.png
10.- Compute thermal buoyancy force, B = g(Tρ_parcel - Tρ_env)/ Tρ_env (where Tρ_env = Tv for unsaturated env)
Picture_17.png
11.- Integrate B over z to get a CAPE like energy. Why not plot a cumulative sum (indefinite integral), it shows more.
Picture_21.png
12.- Now suppose the parcel precipitates. Replace qt0 with a qt profile that is equal to qv of the parcel, and invert again. Notice that now you are passing invert_entropy three arrays of 181 values, not 2 scalars and a p[181] array. But the code will handle it sensibly.

mmm... still figuring out